package com.ljy.jymail.member.web;

import com.alibaba.fastjson.JSON;
import com.ljy.common.utils.R;
import com.ljy.jymail.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

@Controller
public class MemberWebController {

    @Autowired
    OrderFeignService orderFeignService;

    @GetMapping("/memberOrder.html")
    public String memberOrderPage(@RequestParam(value = "pageNum",defaultValue = "1")
                                              Integer pageNum, Model model){
        //request 可以获取支付成功后支付宝传来的所有数据

        //也可以验证支付宝签名，正确就修改

        //查出当前登录的用户的所有订单列表数据
        Map<String, Object> page = new HashMap<>();
        page.put("pageNum", pageNum.toString());
        R result = orderFeignService.listWithItem(page);
//        System.out.println(JSON.toJSONString(result));
        model.addAttribute("orders",result);
        return "orderList.html";
    }

}
